/**
 * Copyright (c) 2016-2019 九点科技 All rights reserved.
 *
 * http://www.9dyun.cn
 *
 * 版权所有，侵权必究！
 */
package com.dian.modules.base.controller;

import java.util.Map;
import java.util.List;
import com.dian.common.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.dian.common.controller.AbstractController;
import com.dian.modules.base.entity.MemberEntity;
import com.dian.modules.base.service.MemberService;
import com.dian.modules.base.vo.MemberExportVO;
import com.dian.common.utils.PageUtils;
import com.dian.common.utils.R;


/**
 * 职员
 *
 * @author zhourui
 * @email 1436907200@qq.com
 * @date 2019-07-04 15:53:32
 */
@RestController
@Api("职员接口")
@RequestMapping("base/member")
public class MemberController extends AbstractController{
    @Autowired
    private MemberService memberService;

    /**
     * 职员列表
     */
    @SysLog("职员列表")
    @GetMapping("/list")
    @ApiOperation("职员列表")
    @RequiresPermissions("base:member:list")
    public R list(@RequestParam Map<String, Object> params){

        PageUtils page = memberService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 职员信息
     */
    @SysLog("职员信息")
    @ApiOperation("职员信息")
    @GetMapping("/info/{id}")
    @RequiresPermissions("base:member:info")
    public R info(@PathVariable("id") Long id){

        MemberEntity member = memberService.getInfo(id);

        return R.ok().put(member);
    }

    /**
     * 职员保存
     */
    @SysLog("职员保存")
    @ApiOperation("职员保存")
    @PostMapping("/save")
    @RequiresPermissions("base:Member:save")
    public R save(@RequestBody MemberEntity member){

		memberService.saveInfo(member);

        return R.ok();
    }

    /**
     * 职员修改
     */
    @SysLog("职员修改")
    @ApiOperation("职员修改")
    @PostMapping("/update")
    @RequiresPermissions("base:member:update")
    public R update(@RequestBody MemberEntity member){

		memberService.updateInfo(member);

        return R.ok();
    }

    /**
     * 职员删除
     */
    @SysLog("职员删除")
    @ApiOperation("职员删除")
    @PostMapping("/delete")
    @RequiresPermissions("base:member:delete")
    public R delete(@RequestBody Long[] ids){

		memberService.deleteInfo(ids);

        return R.ok();
    }




    /**
     * 职员导出
     */
    @SysLog("职员导出")
    @ApiOperation("职员导出")
    @GetMapping("/export")
    @RequiresPermissions("base:member:export")
    public void export(@RequestParam Map<String, Object> params){

        List<MemberExportVO> list = memberService.exportList(params);

        exportExcel(list,"职员","职员",MemberExportVO.class,"职员.xls");
    }

}
